package com.antonytrupe.gamething;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@SuppressWarnings("serial")
public class GamethingServlet extends HttpServlet {

	@Override
	public void doGet(HttpServletRequest request, HttpServletResponse response) {
		response.setContentType("text/html"); //$NON-NLS-1$

		// create the engine object
		GameEngine gameEngine = new GameEngine(request, response);

		try {
			gameEngine.process();
		} catch (RuntimeException e) {
			e.fillInStackTrace();
			gameEngine.io.write(e.getMessage());
			//throw e;
		} catch (Exception e) {
			e.fillInStackTrace();
			gameEngine.io.write(e.getMessage());
		}
	}

	@Override
	public void doPost(HttpServletRequest request, HttpServletResponse response) {
		this.doGet(request, response);
	}
}